#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> arr(7); // 中奖号码
    int hash[7] = {0};  // 最后输出的结果
    for (int i = 0; i < 7; i++)
    {
        cin >> arr[i];
    }
    vector<vector<int>> tmp(n, vector<int>(7));

    int cnt = 0; // 表示中奖的个数

    for (int i = 0; i < n; i++)
    {
        cin >> tmp[i][0] >> tmp[i][1] >> tmp[i][2] >> tmp[i][3] >> tmp[i][4] >> tmp[i][5] >> tmp[i][6];
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 7; j++)
        {
            if (tmp[i][0] == arr[j])
                cnt++;
            else if (tmp[i][1] == arr[j])
                cnt++;
            else if (tmp[i][2] == arr[j])
                cnt++;
            else if (tmp[i][3] == arr[j])
                cnt++;
            else if (tmp[i][4] == arr[j])
                cnt++;
            else if (tmp[i][5] == arr[j])
                cnt++;
            else if (tmp[i][6] == arr[j])
                cnt++;
        }
        // 统计几等奖
        if (cnt == 1)
            hash[6]++;
        else if (cnt == 2)
            hash[5]++;
        else if (cnt == 3)
            hash[4]++;
        else if (cnt == 4)
            hash[3]++;
        else if (cnt == 5)
            hash[2]++;
        else if (cnt == 6)
            hash[1]++;
        else if (cnt == 7)
            hash[0]++;
        cnt = 0;
    }
    for (int i = 0; i < 7; i++)
    {
        cout << hash[i] << " ";
    }
    cout<<endl;

    return 0;
}